package com.lagou.es.config;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @description: kafka配置类
 **/
@Configuration
public class KafkaConfig {

    @Bean
    public KafkaConsumer kafkaConsumer() {
        Properties properties = new Properties();
        //配置端口信息
        properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,"192.168.110.20:9092,192.168.110.20:9093,192.168.110.20:9094");
        //反序列化
        properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
        properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,StringDeserializer.class);
        //定义组名
        properties.put(ConsumerConfig.GROUP_ID_CONFIG,"lagou");
        KafkaConsumer<String, String> kafkaConsumer = new KafkaConsumer<String, String>(properties);
        return kafkaConsumer;
    }
}
